//
//  AM_RootViewController.m
//  AppleMarket
//
//  Created by yangy on 18/10/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "AM_RootViewController.h"

// controller
#import "AM_HomeViewController.h"
#import "AM_MarketViewController.h"
#import "AM_TradeViewController.h"
#import "AM_LegalViewController.h"
#import "AM_TreatyViewController.h"
#import "CM_NavigationViewController.h"

@interface AM_RootViewController ()
@property (nonatomic, strong) AM_HomeViewController *homeVC;     // 首页
@property (nonatomic, strong) AM_MarketViewController *marketVC; // 行情
@property (nonatomic, strong) AM_TradeViewController *tradeVC;   // 币币交易
@property (nonatomic, strong) AM_LegalViewController *legalVC;   // 法币交易
@property (nonatomic, strong) AM_TreatyViewController *treatVC;  // 合约交易
@end

@implementation AM_RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setSubviewControllers];
}


- (void) setSubviewControllers
{
    CM_NavigationViewController *navHome = [[CM_NavigationViewController alloc] initWithRootViewController:self.homeVC];
    CM_NavigationViewController *navMarket = [[CM_NavigationViewController alloc] initWithRootViewController:self.marketVC];
    CM_NavigationViewController *navTrade = [[CM_NavigationViewController alloc] initWithRootViewController:self.tradeVC];
    CM_NavigationViewController *navLegal = [[CM_NavigationViewController alloc] initWithRootViewController:self.legalVC];
    CM_NavigationViewController *navTreat = [[CM_NavigationViewController alloc] initWithRootViewController:self.treatVC];
    
    [self setViewControllers:@[navHome,navMarket,navTrade,navLegal,navTreat]];
    
}

- (AM_HomeViewController *)homeVC
{
    if(!_homeVC){
        _homeVC = [[AM_HomeViewController alloc] init];
        _homeVC.title = @"首页";
        _homeVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_home_sel"];
        _homeVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_home_nor"];
    }
    return _homeVC;
}

- (AM_MarketViewController *)marketVC
{
    if(!_marketVC){
        _marketVC = [[AM_MarketViewController alloc] init];
        _marketVC.title = @"行情";
        _marketVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_market_sel"];
        _marketVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_market_nor"];
    }
    return _marketVC;
}

- (AM_TradeViewController *)tradeVC
{
    if(!_tradeVC){
        _tradeVC = [[AM_TradeViewController alloc] init];
        _tradeVC.title = @"币币";
        _tradeVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_trade_sel"];
        _tradeVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_trade_nor"];
    }
    return _tradeVC;
}

- (AM_LegalViewController *)legalVC
{
    if(!_legalVC){
        _legalVC = [[AM_LegalViewController alloc] init];
        _legalVC.title = @"法币";
        _legalVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_legal_sel"];
        _legalVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_legal_nor"];
    }
    return _legalVC;
}

- (AM_TreatyViewController *)treatVC
{
    if(!_treatVC){
        _treatVC = [[AM_TreatyViewController alloc] init];
        _treatVC.title = @"合约";
        _treatVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_treaty_sel"];
        _treatVC.tabBarItem.image = [UIImage imageNamed:@"tabbar_treaty_nor"];
    }
    return _treatVC;
}


@end
